package com.html;

import org.jsoup.nodes.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.model.xmlElement.DataColumn;
import com.tool.StringUtil;

import constant.HtmlConstant;

/**
 * *********************************************
 * @author Administrator
 * @FileName ParseElement.java
 * @Description解析org.jsoup.nodes.Element
 **********************************************
 */
public class ParseJsoupElement {
	public static final Logger LOG = LoggerFactory.getLogger(ParseJsoupElement.class);
	
	private String seed;
	private DataColumn dataColumn;
	private String outPutType;
	private Element element;
	
	
	public String getSeed() {
		return seed;
	}
	public void setSeed(String seed) {
		this.seed = seed;
	}
	public DataColumn getDataColumn() {
		return dataColumn;
	}
	public void setDataColumn(DataColumn dataColumn) {
		this.dataColumn = dataColumn;
	}
	public String getOutPutType() {
		return outPutType;
	}
	public void setOutPutType(String outPutType) {
		this.outPutType = outPutType;
	}
	public Element getElement() {
		return element;
	}
	public void setElement(Element element) {
		this.element = element;
	}

	public ParseJsoupElement(String seed,DataColumn dataColumn, String outPutType, Element element) {
		super();
		this.seed = seed;
		this.dataColumn = dataColumn;
		this.outPutType = outPutType;
		this.element = element;
	}
	public String parse(){
		String elementValue = null;
		if(outPutType.equals(HtmlConstant.OUTPUTTYPE_TEXT)){
			elementValue = StringUtil.parseContent(element.text());
		}else if(outPutType.equals(HtmlConstant.OUTPUTTYPE_HTML)){
			elementValue = StringUtil.parseContent(ParseImgs.parse(seed, element.outerHtml()));
		}
		if(elementValue != null && !"".equals(elementValue)){
			elementValue = elementValue.replace("\"", "'");
		}
		return elementValue;
	}
	

}
